package prj.carmap.mobile.util;

import android.graphics.Color;

/**
 * 颜色工具类
 *
 */
public class ColorUtil {

	/**
	 * 颜色字符串转整数
	 * @param color
	 * @return
	 */
	public static int colorStr2Int(String color) {
		color = color.replace("#", "");
		int length = color.length();
		if (length == 6)
		{
			return Color.rgb(
					Integer.valueOf(color.substring(0, 2), 16),
					Integer.valueOf(color.substring(2, 4), 16),
					Integer.valueOf(color.substring(4, 6), 16)
					);
		}
		else if (length == 8)
		{
			return Color.argb(
					Integer.valueOf(color.substring(0, 2), 16),
					Integer.valueOf(color.substring(2, 4), 16),
					Integer.valueOf(color.substring(4, 6), 16),
					Integer.valueOf(color.substring(6, 8), 16)
					);
		}
		return 0;
	}
}
